<template>
    <div>
        <!-- 需要接受1个参数 
            AllInfo : 所有的数组
         -->
         <!-- 校验文字   -->
        <ul class="list-ul banxin tanxin">
            <li v-for="item in AllInfo" :key="item.id" @click="more(item.id)">
                <i>
                    <img src="@/assets/images/home/hot-j.png" v-if="item.isHotSale === 1" alt="">
                    <img src="@/assets/images/home/new-j.png" v-if="item.isLatest === 1" alt="">
                </i>
                <img :src="'http://sc.wolfcode.cn'+item.coverImg" alt="">
                <p>{{item.name}}</p>
                <span>{{item.coin}}
                    <img src="@/assets/images/home/monad.png" alt="">
                </span>
                <button>立即兑换</button>
            </li>
        </ul>
    </div>
</template>

<script>
import bus from '@/common/bus'
import { goodsMoreGoodsInfo } from "@/request/Api";
export default {
    data () {
        return {

 
        }
    },
    props :['AllInfo'],
    // {{item.id}} 就是当前页面的id
    methods : {
        // 点击后 请求数据  数据跳转到一个新的页面 more(携带的是id)事件
        more(id){
            // 发送请求 返回一堆数据 
            goodsMoreGoodsInfo(id).then(res =>{
                if(res.data.code === 0){
                    // 将数据返回给兄弟组件 渲染
                    bus.$emit('letInfoToGoods',res.data.data) // 直接传递的时候写上自定义名字
                }
            })
             
            // 控制父组件将此组件隐藏 然后显示兄弟组件
            this.$emit('MyChangeAllOrMore',false)
            // 字传父必须是自定义函数 此函数被点击事件触发
        }
    }

}
</script>
 
<style lang = "less" scoped>
    @import '@/assets/base.less';
    .list-ul {
            flex-wrap: wrap;
            justify-content: start;
            li {
                background-color: white;
                padding-bottom: 30px;
                margin: 25px 0;
                margin-right: 20px;
                cursor: pointer;
                &:nth-of-type(4n){
                    margin-right: 0;
                }
                text-align: center;
                position: relative;
                font-size: 18px;
                transition: all 0.2s ease-in;
                &:hover {
                    transform: translateY(-20px);
                    button {
                        background-color: #0A328E;
                        color: white;
                    }
                    span>img {
                    animation: run 2s ease-out infinite;
                    }
                }
                @keyframes run {
                    0%,10%,20%  { transform: rotateZ(0deg); }
                    5%,15% { transform: rotateZ(45deg); }
                }
                i {
                    img {
                        width: 58px;
                        height: 58px;
                        position: absolute;
                    }
                }
                img {
                    width: 285px;
                    height: 250px;
                    }
                p {
                    margin-top: 22px;
                }
                span {
                    display: block;
                    margin-top: 16px;
                    color: #FD604D;
                    font-weight: bold;
                    img {
                        width: 20px;
                        height: 20px;
                    }
                }
                button {
                    cursor: pointer;
                    margin-top: 20px;
                    width: 100px;
                    height: 36px;
                    border: 1px solid #0A328E;
                    color: #0A328E;
                    font-weight: bold;
                }


            }
            
            

        }
</style>